package com.aspose.cells;

class zck {
   protected zn a;
   protected boolean b = false;
   protected float c;
   protected float d;
   protected zbkr e;
   protected float f = 0.0F;
   protected float g;
   protected float h;
   protected boolean i = false;
   protected boolean j = false;

   zck(zn var1, float var2, float var3, zbkr var4) {
      this.a = var1;
      this.e = var4;
      this.c = var2;
      this.d = var3;
      this.g = this.c;
      this.h = this.d;
      com.aspose.cells.b.a.b.a.zi var5 = new com.aspose.cells.b.a.b.a.zi();
      com.aspose.cells.b.a.b.zq var6;
      com.aspose.cells.b.a.b.zo var7;
      switch(this.e.p()) {
      case 0:
      case 19:
         if (this.e.R() || this.e.Q() || this.e.u() != 0) {
            var5 = this.b(this.e);
         }
         break;
      case 1:
         if (this.e.u() > 0 && (this.e.u() != 180 || !this.e.Q())) {
            if (!this.e.e && !this.e.h) {
               var5 = this.c(this.e);
            } else {
               var5 = this.a(var4.u());
            }
         }
         break;
      case 2:
      case 13:
      case 20:
      case 87:
      case 2061:
         if (var4.u() != 0) {
            var6 = new com.aspose.cells.b.a.b.zq(this.c, this.d, this.e.v().h(), this.e.v().i());
            if (this.e.v().i() == 0.0F || this.e.v().h() == 0.0F) {
               var6 = new com.aspose.cells.b.a.b.zq(this.e.S().f(), this.e.S().g(), this.e.S().h(), this.e.S().i());
            }

            var7 = new com.aspose.cells.b.a.b.zo(var6.f() + var6.h() / 2.0F, var6.g() + var6.i() / 2.0F);
            var5.b(zbuk.a(var7.d()), zbuk.a(var7.e()));
            var5.a((float)var4.u());
            var5.b(-zbuk.a(var7.d()), -zbuk.a(var7.e()));
            this.i = true;
         }
         break;
      case 32:
         if (this.e.n && this.e.e) {
            if (this.e.R() || this.e.Q() || this.e.u() != 0) {
               var5 = this.b(this.e);
            }
         } else if (var4.u() != 0) {
            var6 = new com.aspose.cells.b.a.b.zq(this.c, this.d, this.e.v().h(), this.e.v().i());
            if (this.e.v().i() == 0.0F || this.e.v().h() == 0.0F) {
               var6 = new com.aspose.cells.b.a.b.zq(this.e.S().f(), this.e.S().g(), this.e.S().h(), this.e.S().i());
            }

            var7 = new com.aspose.cells.b.a.b.zo(var6.f() + var6.h() / 2.0F, var6.g() + var6.i() / 2.0F);
            var5.b(zbuk.a(var7.d()), zbuk.a(var7.e()));
            var5.a((float)var4.u());
            var5.b(-zbuk.a(var7.d()), -zbuk.a(var7.e()));
            this.i = true;
         }
         break;
      case 33:
      case 34:
      case 35:
      case 36:
      case 37:
      case 38:
      case 39:
      case 40:
         var5 = this.a(this.e);
         break;
      case 53:
         if (!this.e.Q()) {
            this.e.f(this.e.u() + 180);
            var5 = this.a(this.e.u());
         } else if (this.e.u() > 0) {
            var5 = this.a(this.e.u());
         }
         break;
      case 54:
         if (this.e.Q()) {
            this.e.f(this.e.u() + 180);
            var5 = this.a(this.e.u());
         } else if (this.e.u() > 0) {
            var5 = this.a(this.e.u());
         }
         break;
      default:
         if (this.e.u() > 0) {
            if (!this.e.e && !this.e.h) {
               var5 = this.c(this.e);
            } else {
               var5 = this.a(var4.u());
            }
         }
      }

      this.a.a(var5);
   }

   private com.aspose.cells.b.a.b.a.zi c(zbkr var1) {
      com.aspose.cells.b.a.b.a.zi var2 = new com.aspose.cells.b.a.b.a.zi();
      int var5 = var1.u();
      float var3;
      float var4;
      if ((var5 < 45 || var5 >= 135) && (var5 < 225 || var5 >= 315)) {
         var3 = var1.s() + var1.q() / 2.0F;
         var4 = var1.t() + var1.r() / 2.0F;
      } else if (var1.Y()) {
         var3 = var1.t() + var1.r() / 2.0F;
         var4 = var1.s() + var1.q() / 2.0F;
      } else {
         var3 = var1.s() + var1.q() / 2.0F;
         var4 = var1.t() + var1.r() / 2.0F;
      }

      var2.a((float)var5, new com.aspose.cells.b.a.b.zo(zbuk.a(var3), zbuk.a(var4)));
      if ((var5 >= 45 && var5 < 135 || var5 >= 225 && var5 < 315) && var1.Y()) {
         var2.b(zbuk.a(var1.r() / 2.0F - var1.q() / 2.0F), zbuk.a(var1.q() / 2.0F - var1.r() / 2.0F));
      }

      this.i = true;
      return var2;
   }

   com.aspose.cells.b.a.b.a.ze a(com.aspose.cells.b.a.b.zq var1) {
      return new com.aspose.cells.b.a.b.a.ze();
   }

   void a(zn var1, float var2, float var3, float var4, float var5) {
      com.aspose.cells.b.a.b.zq var6 = new com.aspose.cells.b.a.b.zq(var2, var3, var4, var5);
      com.aspose.cells.b.a.b.a.ze var7 = this.a(var6);
      this.e.a(var7);
      com.aspose.cells.b.a.b.a.zf var8 = var1.e();
      com.aspose.cells.b.a.b.zm var9 = zbum.a(this.e.x());
      var1.a(4);
      var1.a(var9, var7);
      var1.a(var8);
   }

   void b(zn var1, float var2, float var3, float var4, float var5) {
      com.aspose.cells.b.a.b.zq var6 = new com.aspose.cells.b.a.b.zq(var2, var3, var4, var5);
      com.aspose.cells.b.a.b.a.ze var7 = this.a(var6);
      com.aspose.cells.b.a.b.a.zf var8 = var1.e();
      var1.a(4);
      boolean var9 = false;
      if (!this.e.w().a() && this.e.w().c().c() == 0 && !this.e.w().c().b().a()) {
         var9 = true;
      }

      float var10 = this.e.w().c().b().c();
      if (this.i && var9) {
         this.e.w().c().b().a(this.e.w().c().b().c() - (float)this.e.u());
      }

      com.aspose.cells.b.a.b.zc var11 = zbum.a(this.e.w(), var7);
      var1.a(var11, var7);
      var1.a(var8);
      if (var9 && var9) {
         this.e.w().c().b().a(var10);
      }

   }

   void b() {
      new com.aspose.cells.b.a.b.zq(this.c, this.d, this.e.v().h(), this.e.v().i());
      com.aspose.cells.b.a.b.a.zf var2 = this.a.e();
      this.a.a(4);
      if (!this.e.w().a()) {
         this.b(this.a, this.c, this.d, this.e.v().h(), this.e.v().i());
      }

      if (!this.e.x().a()) {
         this.a(this.a, this.c, this.d, this.e.v().h(), this.e.v().i());
      }

      this.a();
      this.a.a(var2);
   }

   com.aspose.cells.b.a.b.zq b(com.aspose.cells.b.a.b.zq var1) {
      if (this.e.j.getTextVerticalAlignment() == 1 && var1.i() < (float)this.e.y().d()) {
         var1.b((var1.i() + var1.g() * 2.0F - (float)this.e.y().d()) / 2.0F);
      }

      return var1;
   }

   void a() {
      this.c(this.e.v());
   }

   void c(com.aspose.cells.b.a.b.zq var1) {
      if (!this.e.G().equals("\n")) {
         float var4;
         float var5;
         float var6;
         if (this.e.q && this.e.p() == 1) {
            int var15 = this.a.j();
            this.a.b(4);
            com.aspose.cells.b.a.b.zt var14;
            if (this.e.G().length() > 1) {
               var14 = this.a.a(this.e.G(), this.e.y());
               var4 = var14.b() / (float)this.e.G().length();
               var5 = (var1.h() - (var14.b() - var1.h() - var4 * 2.0F / 3.0F)) / var1.h();
               var6 = 1.0F;
               if (var14.c() > var1.i() && !this.e.n) {
                  var6 = (var1.i() + (var14.c() - var1.i()) / 2.0F) / var14.c();
               }

               com.aspose.cells.b.a.b.a.zi var17 = new com.aspose.cells.b.a.b.a.zi(var5, 0.0F, 0.0F, var6, 0.0F, var6 * zbuk.a(-(var14.c() - var1.i()) / 2.0F) + 1.0F);
               this.a.a(var17, 1);
               var1.c(var1.h() + var4 / 2.0F);
            } else {
               var14 = this.a.a(this.e.G(), this.e.y());
               com.aspose.cells.b.a.b.a.zi var16 = new com.aspose.cells.b.a.b.a.zi(var14.c() / var1.i(), 0.0F, 0.0F, var14.b() / var1.h(), 0.0F, zbuk.a(var1.h() - var14.b()));
               this.a.a(var16, 1);
            }

            zbum.a(this.a, this.e, var1, this.e.G(), this.e.D(), this.e.y(), this.e.z(), this.e.A(), this.e.B(), this.e.C());
            this.a.b(var15);
         } else {
            var1.a(var1.f() + (float)this.e.k().a());
            var1.c(var1.h() - (float)(this.e.k().a() + this.e.k().c()));
            var1.b(var1.g() + (float)this.e.k().b());
            var1.d(var1.i() - (float)(this.e.k().b() + this.e.k().d()));
            float var2;
            if (var1.i() < (float)this.e.y().d() && this.e.j.getTextVerticalOverflow() != 2) {
               var2 = ((float)this.e.y().d() - var1.i()) / 2.0F;
               var1 = new com.aspose.cells.b.a.b.zq(var1.f(), var1.g() - var2, var1.h(), (float)this.e.y().d());
            }

            if (var1.i() > (float)(2 * this.e.y().d()) * 0.8F && var1.i() < (float)(2 * this.e.y().d())) {
               var2 = ((float)(2 * this.e.y().d()) - var1.i()) / 2.0F;
               var1 = new com.aspose.cells.b.a.b.zq(var1.f(), var1.g() - var2, var1.h(), (float)(2 * this.e.y().d()));
            }

            if (this.e.u() == 0 && this.d() && var1.h() < (float)this.e.y().d()) {
               var2 = ((float)this.e.y().d() - var1.h()) / 2.0F;
               var1 = new com.aspose.cells.b.a.b.zq(var1.f() - var2, var1.g(), (float)this.e.y().d(), var1.i());
            }

            if (this.e.o != 0) {
               var1.a(var1.f() + (float)(this.e.o * 48));
            }

            var1 = this.b(var1);
            com.aspose.cells.b.a.b.a.zf var13 = null;
            if (this.e.F() == 1) {
               var13 = this.a.e();
               float var3 = var1.f() + var1.h() / 2.0F;
               var4 = var1.g() + var1.i() / 2.0F;
               var5 = 1.0F;
               var6 = 1.0F;
               double var7 = 0.0D;
               if (this.i) {
                  var7 = this.e.j.getRotationAngle();
               }

               if (this.j) {
                  if (this.e.j.isFlippedHorizontally()) {
                     var5 = -var5;
                  }

                  if (this.e.j.isFlippedVertically()) {
                     var6 = -var6;
                  }
               }

               var7 = (double)(var5 * var6) * var7;

               Shape var10;
               for(Shape var9 = this.e.j; var9.S(); var9 = var10) {
                  var10 = (Shape)var9.F();
                  if (var10.isFlippedHorizontally()) {
                     var5 = -var5;
                  }

                  if (var10.isFlippedVertically()) {
                     var6 = -var6;
                  }

                  double var11 = (double)(var5 * var6) * var10.getRotationAngle();
                  var7 += var11;
               }

               var7 = (double)((float)(var7 % 360.0D));
               com.aspose.cells.b.a.b.a.zi var18 = new com.aspose.cells.b.a.b.a.zi();
               var18.b(zbuk.a(var3), zbuk.a(var4));
               var18.a(-((float)var7));
               com.aspose.cells.b.a.b.a.zi var19 = new com.aspose.cells.b.a.b.a.zi(var5, 0.0F, 0.0F, var6, 0.0F, 0.0F);
               var18.a((com.aspose.cells.b.a.b.a.zi)var19, 0);
               var18.b(-zbuk.a(var3), -zbuk.a(var4));
               this.a.a(var18);
            }

            zbum.a(this.a, this.e, var1, this.e.G(), this.e.D(), this.e.y(), this.e.z(), this.e.A(), this.e.B(), this.e.C());
            if (this.e.F() == 1) {
               this.a.a(var13);
            }

         }
      }
   }

   private boolean d() {
      if (this.e.D() == 3) {
         return false;
      } else {
         boolean var1 = false;
         byte var2;
         switch(this.e.D()) {
         case 0:
            var2 = -90;
            break;
         case 1:
            var2 = 90;
            break;
         default:
            var2 = 0;
         }

         int var3 = var2 - (int)this.e.E();
         var3 = Math.abs(var3) % 360;
         return var3 == 90 || var3 == 270;
      }
   }

   private com.aspose.cells.b.a.b.a.zi a(int var1) {
      com.aspose.cells.b.a.b.a.zi var2 = new com.aspose.cells.b.a.b.a.zi();
      com.aspose.cells.b.a.b.zq var3 = new com.aspose.cells.b.a.b.zq(this.c, this.d, this.e.v().h(), this.e.v().i());
      com.aspose.cells.b.a.b.zo var4 = new com.aspose.cells.b.a.b.zo(var3.f() + var3.h() / 2.0F, var3.g() + var3.i() / 2.0F);
      var2.b(zbuk.a(var4.d()), zbuk.a(var4.e()));
      var2.a((float)var1);
      var2.b(-zbuk.a(var4.d()), -zbuk.a(var4.e()));
      this.i = true;
      return var2;
   }

   com.aspose.cells.b.a.b.a.zi a(zbkr var1) {
      float var2;
      float var3;
      if ((var1.u() < 45 || var1.u() >= 135) && (var1.u() < 225 || var1.u() >= 315)) {
         var2 = var1.s() + var1.q() / 2.0F;
         var3 = var1.t() + var1.r() / 2.0F;
      } else {
         var2 = var1.t() + var1.r() / 2.0F;
         var3 = var1.s() + var1.q() / 2.0F;
      }

      com.aspose.cells.b.a.b.a.zi var4 = new com.aspose.cells.b.a.b.a.zi(var1.R() ? -1.0F : 1.0F, 0.0F, 0.0F, var1.Q() ? -1.0F : 1.0F, var1.R() ? zbuk.a(var2 * 2.0F) : 0.0F, var1.Q() ? zbuk.a(var3 * 2.0F) : 0.0F);
      this.j = true;
      var4.a(var1.R() ^ var1.Q() ? (float)(-var1.u()) : (float)var1.u(), new com.aspose.cells.b.a.b.zo(zbuk.a(var2), zbuk.a(var3)));
      this.i = true;
      if (var1.u() >= 45 && var1.u() < 135 || var1.u() >= 225 && var1.u() < 315) {
         if (!var1.h && !var1.e) {
            var4.b(zbuk.a(var1.r() / 2.0F - var1.q() / 2.0F), zbuk.a(var1.q() / 2.0F - var1.r() / 2.0F));
         } else if (var1.u() == 270 && !var1.Q() && !var1.R()) {
            var4.b(zbuk.a(var1.r() / 2.0F - var1.q() / 2.0F), zbuk.a(var1.s() + var1.q() / 2.0F));
         }
      }

      return var4;
   }

   com.aspose.cells.b.a.b.a.zi b(zbkr var1) {
      float var2;
      float var3;
      if (!var1.e) {
         if ((var1.u() < 45 || var1.u() >= 135) && (var1.u() < 225 || var1.u() >= 315)) {
            var2 = var1.s() + var1.q() / 2.0F;
            var3 = var1.t() + var1.r() / 2.0F;
         } else {
            var2 = var1.t() + var1.r() / 2.0F;
            var3 = var1.s() + var1.q() / 2.0F;
         }
      } else {
         var2 = var1.s() + var1.q() / 2.0F;
         var3 = var1.t() + var1.r() / 2.0F;
      }

      com.aspose.cells.b.a.b.a.zi var4 = new com.aspose.cells.b.a.b.a.zi(var1.R() ? -1.0F : 1.0F, 0.0F, 0.0F, var1.Q() ? -1.0F : 1.0F, var1.R() ? zbuk.a(var2 * 2.0F) : 0.0F, var1.Q() ? zbuk.a(var3 * 2.0F) : 0.0F);
      this.j = true;
      var4.a(var1.R() ^ var1.Q() ? (float)(-var1.u()) : (float)var1.u(), new com.aspose.cells.b.a.b.zo(zbuk.a(var2), zbuk.a(var3)));
      this.i = true;
      return var4;
   }

   public void c() {
      this.a(true);
      com.aspose.cells.b.a.zg.a(this);
   }

   protected void a(boolean var1) {
      if (!this.b) {
         if (var1) {
            ;
         }

         this.b = true;
      }

   }

   protected void finalize() throws Exception {
      this.c();
   }
}
